package cn.fintecher.ams.service.attendance.web;

import cn.fintecher.ams.service.attendance.common.ResponseResult;
import cn.fintecher.ams.service.attendance.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/4/17.
 */
@RestController
@RequestMapping("/api/userController")
@Api(description = "用户相关")
public class UserController {

    private final  static Log logger = LogFactory.getLog(UserController.class);
    @Autowired
    UserService userService;

    @GetMapping("/getUser")
    @ApiOperation(value = "根据用户名获取用户", notes = "根据用户名获取用户")
    public ResponseResult test(@RequestParam @ApiParam(value = "用户名", required = true) String userName){
        logger.error("test------->" + userName);
        return userService.getUserByName(userName);
    }
    @GetMapping("/list")
    @ApiOperation(value = "分页查询用户", notes = "分页查询用户")
    public ResponseResult list(@RequestParam(required = false) @ApiParam(value = "用户名") String userName,
                               @RequestParam(required = false) @ApiParam(value = "真实姓名") String realName,
                               @RequestParam @ApiParam(value = "页码，1开始", required = true) Integer page,
                               @RequestParam @ApiParam(value = "每页条数", required = true) Integer size) throws Exception{

        return userService.list(userName,realName,page,size);
    }
}
